﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SomeRandomGame.Interfaces;
using SomeRandomGame.Utility;

namespace SomeRandomGame
{
    public class Player :IPlayer
    {
        private IShip _ship;
        private Vector2 _startPosition;
        private PlayerIndex _playerIndex;

        public Player( PlayerIndex playerIndex, IShip ship, Vector2 startPosition )
        {
            _ship = ship;
            _startPosition = startPosition;
            _playerIndex = playerIndex;
        }

        public PlayerIndex PlayerIndex
        {
            get { return _playerIndex; }
        }

        public IShip Ship
        {
            get { return _ship; }
            set { _ship = value; }
        }

        public Vector2 Position
        {
            get { return _ship.Position; }
            set { _ship.Position = value; }
        }

        public int Width { get { return _ship.Width; } }
        public int Height { get { return _ship.Height; } }
        public bool Active { get { return true; } }

        public void Initialize( IGameManager gameManager )
        {
            _ship.Initialize( gameManager );
            _ship.Position = _startPosition;
        }

        public void Update( IGameManager gameManager )
        {
            _ship.Update( gameManager );
        }

        public void Update( IGameManager gameManager, IInputManager inputManager )
        {
            _ship.Move( PlayerIndex, gameManager, inputManager );
            _ship.Gun.Shoot(gameManager, inputManager);
            Update( gameManager );
        }

        public void Draw( SpriteBatch spriteBatch, IGameManager gameManager, GameTime gameTime )
        {
            _ship.Draw( spriteBatch, gameManager, gameTime );
        }
    }
}
